package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.FieldDataMapper;
import com.ruoyi.system.domain.FieldData;
import com.ruoyi.system.service.IFieldDataService;

/**
 * 业务数据字段Service业务层处理
 *
 * @author chenming
 * @date 2024-10-16
 */
@Service
public class FieldDataServiceImpl extends ServiceImpl<FieldDataMapper, FieldData> implements IFieldDataService
{
    @Autowired
    private FieldDataMapper fieldDataMapper;

    /**
     * 查询业务数据字段
     *
     * @param fieldId 业务数据字段主键
     * @return 业务数据字段
     */
    @Override
    public FieldData selectFieldDataByFieldId(Long fieldId)
    {
        return fieldDataMapper.selectFieldDataByFieldId(fieldId);
    }

    /**
     * 查询业务数据字段列表
     *
     * @param fieldData 业务数据字段
     * @return 业务数据字段
     */
    @Override
    public List<FieldData> selectFieldDataList(FieldData fieldData)
    {
        return fieldDataMapper.selectFieldDataList(fieldData);
    }

    /**
     * 新增业务数据字段
     *
     * @param fieldData 业务数据字段
     * @return 结果
     */
    @Override
    public int insertFieldData(FieldData fieldData)
    {
        if(StringUtils.isEmpty(fieldData.getFieldType())){
            fieldData.setFieldType(Constants.FLAG_1+"");
        }
        return fieldDataMapper.insertFieldData(fieldData);
    }

    /**
     * 修改业务数据字段
     *
     * @param fieldData 业务数据字段
     * @return 结果
     */
    @Override
    public int updateFieldData(FieldData fieldData)
    {
        return fieldDataMapper.updateFieldData(fieldData);
    }

    /**
     * 批量删除业务数据字段
     *
     * @param fieldIds 需要删除的业务数据字段主键
     * @return 结果
     */
    @Override
    public int deleteFieldDataByFieldIds(Long[] fieldIds)
    {
        return fieldDataMapper.deleteFieldDataByFieldIds(fieldIds);
    }

    /**
     * 删除业务数据字段信息
     *
     * @param fieldId 业务数据字段主键
     * @return 结果
     */
    @Override
    public int deleteFieldDataByFieldId(Long fieldId)
    {
        return fieldDataMapper.deleteFieldDataByFieldId(fieldId);
    }
}
